<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>登录</title>
		<script src="../js/index1.js"></script>
		<link rel="stylesheet" href="../css/style.css">
		<link rel="stylesheet" href="../css/common.css">
		<script src="../js/rem-config.js"></script>

	</head>
	<body>
		<div class="l_ruturn">
			<a href="mine.html">
				<img src="../images/retuen.png" alt="">
			</a>
		</div>
		<div class="l_title">
			<p>您好，雪竹分期</p>
		</div>
		<div class="l_content">
			<div class="l_phone">
				<p>手机号</p>
				<input type="text" placeholder="请输入手机号" class="reg_phone">
			</div>
			<div class="l_phone">
				<p>验证码</p>
				<div class="l_yz_num">
					<input type="text" placeholder="请输入验证码" class="reg_yzm">
					<button>获取验证码</button>
					<div class="clear"></div>
				</div>
			</div>
			<div class="l_xieyi">
				<input type="checkbox">
				<span>同意<a href="">《雪竹分期用户协议》</a>
				</span>
			</div>
		</div>
		<div class="l_loginbtn">
			登录
		</div>
		<div class="msg"></div>
		<script src="../js/jquery.js"></script>
		<script>
			$(function(){
				$('.reg_phone').blur(function(){
					if($(this).val()== ""){
						$('.msg').show().text("手机号不能为空")
						$(this).focus();
						setTimeout(function(){
							$('.msg').hide("slow");
							
						},2000)
						return false;
					}else{
						var _phone = $(this).val();
						var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
						if(!myreg.test(_phone)){
							$('.msg').show().text("手机号不合法")
							setTimeout(function(){
								$('.msg').hide("slow")	
							},2000)
							$(this).focus()
						}
					}
				});
				$('.reg_yzm').blur(function(){
					if($(this).val()==""){
						$('.msg').show().text("验证码不能为空")
						setTimeout(function(){
							$('.msg').hide("slow")
						},2000)
						return false;
					}else{
						var _yzm = $(this).val();
						var myreg = /^\d{4}$/;
						if(!myreg.test(_yzm)){
							$(".msg").show().text("验证码不合法")
							setTimeout(function(){
								$('.msg').hide("slow")
							},2000);
							$(this).focus();
						}
					}
				});
				//添加点击事件
				$('.l_loginbtn').click(function(){
					var _phone = $('.reg_phone').val();
					var _yzm = $('.reg_yzm').val();
					var _data = {
						"iphone" : _phone,
						"verificationCode" : _yzm
					}
                    $.ajax({
						url:appPath+"login",
//						url:"http://localhost:8080/login",
                        data:JSON.stringify(_data),
                        contentType: "application/json;charset=utf-8",
						dataType:'json',//服务器返回json格式数据
						type:'post',//HTTP请求类型
						success:function(res){
							if(res.success){
								$('.msg').show().text("登陆成功！1秒后跳转页面");
                                window.location.href="wenxin.html";
							}else{
								$('.msg').show().text("注册失败！原因"+res.errorCode)
								setTimeout(function(){
									$('.msg').hide("slow")
								},2000)
							}
						},
						
					});
				})
			})
		</script>
	</body>
</html>
